//
//  UIBarButtonItem + Extension.swift
//  WeiBoTest
//
//  Created by 任帅 on 2017/2/28.
//  Copyright © 2017年 RENSHUAI. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    
    /// 创建UIbarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: CGFloat = 16
    ///   - target: self
    ///   - action: action
    ///   - isBackButton:是否是返回按钮，如果是加上箭头
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject?,action:Selector,isBackButton:Bool = false) {
        
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBackButton{
        
            btn.setImage(UIImage(named:"navigationbar_back_withtext"), for: .normal)
            btn.setImage(UIImage(named:"navigationbar_back_withtext_highlighted"), for: .highlighted)
            btn.sizeToFit()
            
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        //实例化UIBarButtonItem
        self.init(customView:btn)
    }
}
